package com.cqut.ktpspring.controller;

import com.cqut.ktpspring.pojo.Answer;
import com.cqut.ktpspring.pojo.Result;
import com.cqut.ktpspring.service.AnswerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@Slf4j
@RestController
public class AnswerController {
    @Autowired
    private AnswerService answerService;
    @PostMapping("/addAnswer")
    public Result addAnswer(@RequestParam String userId, @RequestParam String wId) {
        log.info("添加学生的作业情况{}，{}", userId, wId);
        answerService.addAnswer(userId,wId);
        return Result.success();
    }



    @PutMapping("/revise")
    public Result revise(@RequestParam String userId, @RequestParam String wId,
                         @RequestParam Integer score) {
        log.info("批改学生作业{}，{}，{}", userId, wId, score);
        answerService.revise(userId, wId, score);
        return Result.success();
    }


    @PutMapping(value = "/submit")
    public Result submit(@RequestParam String userId, @RequestParam String wId,
                          @RequestParam String answerText) {
        log.info("学生提交作业{}，{}，{}", userId, wId, answerText);
        answerService.submit(userId, wId, answerText);
        return Result.success();
    }
}
